/*
 * @version: 1.0
 * @Author: zhl
 * @Date: 2021-09-01 15:16:25
 * @LastEditors: zhl
 * @LastEditTime: 2022-01-27 15:28:23
 * @Description: file content
 */
#include "Server-APDU.h"
#include "Parse_Packet.h"


Server_APDU Server_APDU::c_instance;

Server_APDU::Server_APDU(){

}

Server_APDU::~Server_APDU(){

}

int Server_APDU::parse_apdu(int64_t dev_id, uint8_t *apdu, int len, std::list<Data> &result){

    if((NULL == apdu) || (1 > len)){
        return -1;
    }
    APDU_TAG_TYPE repType = *((APDU_TAG_TYPE *)apdu);
    if(repType == SERVER_GET_RESPONSE){
        return GetResponse::getInstance().parse_response(dev_id, apdu+sizeof(APDU_TAG_TYPE), len-sizeof(APDU_TAG_TYPE), result);
    } else if(repType == SERVER_ERROR_RESPONSE){
        return GetResponse::getInstance().parse_error_response(dev_id, apdu+sizeof(APDU_TAG_TYPE), len-sizeof(APDU_TAG_TYPE));
    }
    return -1;
}
//
Server_APDU &Server_APDU::getInstance(){
    return c_instance;
}